package controller

import (
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
	"gowork/singleTableOrderRules/model"
)

type RuleController struct {
	Ctx  iris.Context
	Order *model.Order
}

func (rc *RuleController)PostInsertorder() mvc.Result {

	rc.Order = new(model.Order)

	var putOrder model.PutOrder
	rc.Ctx.ReadJSON(&putOrder)

	res, err := rc.Order.InsertOrder(&putOrder)
	if err != nil{
		return mvc.Response{
			Object : map[string]interface{}{"message": err.Error(), "data": nil, "code":500,},
		}
	}

	return mvc.Response{
		Object : map[string]interface{}{"message": res["message"], "data": nil, "code":res["code"],},
	}
}
